<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "tmall1.member_info".
 *
 * @property integer $uid
 * @property integer $member_group
 * @property integer $member_type
 * @property integer $lkt_uid
 * @property string $username
 * @property string $member_pass
 * @property string $true_name
 * @property string $cell
 * @property integer $cell_active
 * @property string $email
 * @property integer $email_active
 * @property integer $member_point
 * @property double $member_money
 * @property integer $vip_endtime
 * @property integer $is_vip
 * @property integer $is_autoemail
 * @property integer $is_autosms
 * @property string $salt
 * @property integer $addtime
 * @property integer $lastlogintime
 * @property integer $emailtime
 * @property string $firstsaledate
 * @property string $lastsaledate
 * @property integer $isnewyear
 */
class MemberInfoBestry extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'tmall1.member_info';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['member_group', 'member_type', 'lkt_uid', 'cell_active', 'email_active', 'member_point', 'vip_endtime', 'is_vip', 'is_autoemail', 'is_autosms', 'addtime', 'lastlogintime', 'emailtime', 'isnewyear'], 'integer'],
            [['lkt_uid', 'username', 'member_pass', 'true_name', 'cell', 'email', 'salt'], 'required'],
            [['member_money'], 'number'],
            [['firstsaledate', 'lastsaledate'], 'safe'],
            [['username', 'true_name', 'email'], 'string', 'max' => 60],
            [['member_pass'], 'string', 'max' => 32],
            [['cell'], 'string', 'max' => 11],
            [['salt'], 'string', 'max' => 6],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'uid' => '自增长id',
            'member_group' => '用户组',
            'member_type' => '是否注册用户，1是，0共登',
            'lkt_uid' => '喜试网uid',
            'username' => '昵称：邮箱或手机号',
            'member_pass' => 'Member Pass',
            'true_name' => '真实姓名',
            'cell' => '手机号',
            'cell_active' => '手机是否激活 1为激活 0为未激活',
            'email' => '邮箱',
            'email_active' => '邮箱是否激活 1为激活 0为未激活,-1为已发送激活邮件',
            'member_point' => '积分',
            'member_money' => '帐户余额',
            'vip_endtime' => 'vip结束时间',
            'is_vip' => '是否VIP：1是 0不是',
            'is_autoemail' => 'Is Autoemail',
            'is_autosms' => 'Is Autosms',
            'salt' => 'Salt',
            'addtime' => 'Addtime',
            'lastlogintime' => 'Lastlogintime',
            'emailtime' => 'Emailtime',
            'firstsaledate' => 'Firstsaledate',
            'lastsaledate' => 'Lastsaledate',
            'isnewyear' => 'Isnewyear',
        ];
    }

    /**
     * @inheritdoc
     * @return \services\models\MemberInfoBestryQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \services\models\MemberInfoBestryQuery(get_called_class());
    }

    public static function MoneyTotal($uid){
        $item = static::findOne(['uid'=>$uid]);
        return (float)$item->member_money;
    }
}
